home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Tools⁄Additions / Mandlebrot / Mandlebrot Folder / MenuUpdate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-09  |  3.6 KB  |  121 lines  |  [TEXT/KAHL]

  1. /* *********************************************************************************
  2.      
  3.       FILE:            MenuUpdate.c
  4.       
  5.      DESCRIPTION:    Update Menus uses the unused space on the menu bar to display
  6.                      the three parameters: 'x' (center x location), 'y' (center y 
  7.                      location), 'res'(resolution) and time through each major loop. 
  8.                      Uses 'sprintf' from 'stdio' and 'CtoPstr' to do all the 
  9.                      formating and conversions.  This requires either the ANSI or
  10.                     ANSI881 libraries.  This seems like a lot of baggage to carry 
  11.                     around, but I got tired of trying extract out just the necessary 
  12.                     string processing pieces.  I turned off pointer checking for this
  13.                     compile because I also got tired of looking for the proper way 
  14.                     to get sprintf to work with a declaration of Str255 for str1 
  15.                     (which is necessary to keep the application from crashing).
  16.                       
  17.      AUTHOR:        Bruce E. Gladstone
  18.      
  19.      Copyright © 1990 by Bruce E. Gladstone, All Rights Reserved.
  20.      
  21.      Revision History:
  22.      ============================================================
  23.      5/1/90    - Release to Compuserve
  24.      ============================================================
  25.      
  26.      COMMENTS:
  27.      
  28.      None. 
  29.  
  30.    ******************************************************************************** */        
  31.  
  32. #include <stdio.h> 
  33. #include <MacTypes.h> 
  34. #include <WindowMgr.h>
  35. #include <MenuMgr.h>
  36. #include <EventMgr.h>
  37. #include <ToolboxUtil.h> 
  38. #include <ControlMgr.h>
  39. #include <color.h>
  40. #include <colortoolbox.h>
  41. #include "Mandelbrot.h"
  42.  
  43.  
  44. /* ---------------------------- Global Variables ---------------------------------- */
  45.  
  46. extern int                colorQD;
  47. extern int                quitFlag;
  48. extern int                linearFlag;
  49. extern int                custPict;
  50. extern int                numColorBits;
  51. extern int                numColors, brushSize;
  52. extern int                limit;
  53. extern int                n;
  54. extern long                startTime, now;
  55. extern float            res;
  56. extern float            centx, centy;
  57. extern float            xmin, xmax, ymin, ymax;
  58. extern float            delx, dely;
  59.  
  60. /* ---------------------------- Global MacTypes ----------------------------------- */
  61.  
  62. extern Str255            str;
  63. extern CTabHandle        myColorHandle;
  64. extern RGBColor            aColor;
  65. extern Rect                myRect, dragRect;
  66. extern WindowPtr        aboutWindow;        
  67. extern MenuHandle        appleMenu, mandelMenu, editMenu, xMenu, yMenu, resMenu, timeMenu;
  68. extern WindowPtr        myWindow;
  69.  
  70. /* ---------------------------  Local Prototypes  --------------------------------- */
  71.  
  72. void updateMenus ( void );
  73. void CtoPstr ( char * );
  74.  
  75. /* --------------------------------------------------------------------------------
  76.     updateMenus - 5/01/90 beg
  77.    -------------------------------------------------------------------------------- */
  78.  
  79. void
  80. updateMenus()
  81. {
  82.     Str255        str1;
  83.     
  84.     DeleteMenu ( xID );
  85.     DeleteMenu ( yID );
  86.     DeleteMenu ( resID );
  87.     DeleteMenu ( timeID );
  88.     DisposeMenu ( xMenu );
  89.     DisposeMenu ( yMenu );
  90.     DisposeMenu ( resMenu );
  91.     DisposeMenu ( timeMenu );
  92.     
  93.     sprintf ( str1, "X = %1.6f", centx );
  94.     CtoPstr ( str1 );
  95.     xMenu = NewMenu ( xID, str1 );
  96.     
  97.     sprintf ( str1, "Y = %1.6f", centy );
  98.     CtoPstr ( str1 );
  99.     yMenu = NewMenu ( yID, str1 );
  100.     
  101.     sprintf ( str1, "Res = %1.6f", res );
  102.     CtoPstr ( str1 );
  103.     resMenu = NewMenu ( resID, str1 );
  104.     
  105.     sprintf ( str1, "Time = %4ld", now );
  106.     CtoPstr ( str1 );
  107.     timeMenu = NewMenu ( timeID, str1 );
  108.     
  109.     InsertMenu ( xMenu, 0 );
  110.     InsertMenu ( yMenu, 0 );
  111.     InsertMenu ( resMenu, 0 );
  112.     InsertMenu ( timeMenu, 0 );    
  113.     DrawMenuBar ();
  114. } /*  updateMenus()  */
  115.  
  116. /* ===============================  EOF  ==========================================
  117.     Copyright © 1990 by Bruce E. Gladstone, All Rights Reserved.
  118.    ================================================================================ */
  119.  
  120.  
  121.